package cn.wolfcode.service.impl;

import cn.wolfcode.domain.Department;
import cn.wolfcode.mapper.DepartmentMapper;
import cn.wolfcode.qo.QueryObject;
import cn.wolfcode.service.IDepartmentService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DepartmentServiceImpl implements IDepartmentService{
    @Autowired
    private DepartmentMapper departmentMapper;

    public void delete(Long id) {
        departmentMapper.deleteByPrimaryKey(id);
    }

    public void insert(Department department) {
        departmentMapper.insert(department);
    }

    public Department select(Long id) {
        return departmentMapper.selectByPrimaryKey(id);
    }

    public List<Department> listAll() {
        return departmentMapper.selectAll();
    }

    public void update(Department department) {
       departmentMapper.updateByPrimaryKey(department);
    }

    public PageInfo<Department> query(QueryObject qo) {

        PageHelper.startPage(qo.getPageNum(),qo.getPageSize());
        List<Department> result=departmentMapper.selectForList(qo);

        return new PageInfo(result);
    }


}
